function a = solveelipseInv( el )
%SOLVEELIPSEINV Summary of this function goes here
% Given an ellipse in the standard form:
%        ((x-cx)/r1)^2 + ((y-cy)/r2)^2 = 1
%         el = [r1 r2 cx cy theta]
% finds the form:
%        a(1)x^2 + a(2)xy + a(3)y^2 + a(4)x + a(5)y + a(6) = 0

r1 = el(1);
r2 = el(2);
c  = el(3);
d  = el(4);
theta = el(5);

ct = cos(theta);
st = sin(theta);
s1 = c*ct+d*st;
s2 = d*ct-c*st;

a = zeros(1,6);
a(1) = (r1*st)^2+(r2*ct)^2;
a(2) =  2*r2^2*ct*st-2*r1^2*ct*st;
a(3) = (r1*ct)^2+(r2*st)^2;
a(4) =  2*r1^2*st*s2 - 2*r2^2*ct*s1;
a(5) = -2*ct*r1^2*s2 - 2*st*r2^2*s1;
a(6) =  (s2*r1)^2 + (s1*r2)^2 - (r1*r2)^2;
a = a / sum(abs(a));
end

